<!DOCTYPE html>
<html>
<head>
    {include file="../application/common/header.html" /}
</head>

<body>
    <table id="peiyou_totaldg"></table>
    <div id="peiyou_totaltb">
        <form id="peiyou_totalForm" class="m5">
            <div>
                学期：
                <select class="easyui-combobox" name="termId" id="termId" data-options="width:120,panelHeight:'auto',value:'请选择', editable:false,textField:'学期名称',valueField:'ID',url:'/compent/Util/termList',onSelect:changeTerm"></select>
                <select id="gradeId" class="easyui-combobox" data-options="width:80,panelHeight:'auto',url:'/compent/Util/gradeNameList',onSelect:changeGrade">
                </select>
                <select id="examId" class="easyui-combobox" data-options="width:120,panelHeight:'auto',editable:false"></select>
                <select id="clazzType" class="easyui-combobox" data-options="width:80,panelHeight:'auto'">
                    <option value="0" selected>天佑班</option>
                    <option value="1">有为班</option>
                    <option value="2">火箭班</option>
                    <option value="3">国际部</option>
                </select>
                <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-search'" onclick="queryOk('peiyou_total')">查询</a>
                <a class="easyui-linkbutton" href="javascript:void(0)" data-options="iconCls:'icon-save'" onclick="zoutExcel('peiyou_total','/examScore/peiyou_total')">导出为EXCEL</a>
            </div>
        </form>
    </div>
    <script type="text/javascript">
        var url = "/examScore/peiyou_total";
        $(function(){
            $("#peiyou_totaldg").datagrid({
                url: url + "/pageQuery.html",
                rownumbers:true,
                striped:true,
                border:false,
                pagination:false,
                fitColumns:true,
                fit:true,
                toolbar: '#peiyou_totaltb'
            })
        })  
        function changeTerm(record){
            var gradeId = $('#gradeId').combobox('getValue');
            if(gradeId) {
                var url="/compent/util/getTermExam?termId="+record.ID+"&grade="+gradeId;
                $('#examId').combobox('setValue','');
                $('#examId').combobox('reload',url);
            }
        }
        function changeGrade(record) {
            var termId = $('#termId').combobox('getValue');
            var url="/compent/util/getTermExam?termId="+termId+"&grade="+record.value;
            $('#examId').combobox('setValue','');
            $('#examId').combobox('reload',url);
        }
        function queryOk(){
            var examId = $('#examId').combobox('getValue');
            var clazzType = $('#clazzType').combobox('getValue');
            if(examId){
                $.post(url + "/getFields",{examId:examId,clazzType:clazzType},function(data){
                    var txArr=data.split(",");
                    var zdArr=[];   
                    var txshu=txArr.length;
                    for(var i=0;i<=txshu-1;i++){
                        zdArr.push({field:txArr[i],title:txArr[i]});
                    }
                    $("#peiyou_totaldg").datagrid({columns:[zdArr]});
                    $('#peiyou_totaldg').datagrid('load',{examId:examId,clazzType:clazzType});
                })
            }else{
                $.messager.alert('操作提示','请选择考试名称。');
            }
        }
        function zoutExcel(cf,url){
            var examId = $('#examId').combobox('getValue');
            var clazzType = $('#clazzType').combobox('getValue');
            if(examId){
               window.location.href = url+"/exportExcel.html?examId="+examId+"&clazzType="+clazzType;
            }else{
                $.messager.alert('操作提示','请选择考试名称。');
            }
        }
    </script>
</body>
</html>